package Concurrency.basic;

/**
 * 内存可见性问题：一个线程对一个共享变量的修改，另一个线程不一定马上就能看到，甚至永远也看不到
 */

public class VisibilityDemo {
    private static boolean shutdown = false;

    static class HelloThread extends  Thread {
        @Override
        public void run() {
            while (!shutdown) {

            }
            System.out.println("exit hello");
        }
    }

    public static void main(String[] args) throws InterruptedException {
        new HelloThread().start();
        Thread.sleep(1000);
        shutdown = false;
        System.out.println("exit main");
    }
}
